#include "pch.h"
#include "RectangleDisplayItem.h"
#include "DisplayContext.h"
using namespace D2D1;

RectangleDisplayItem::RectangleDisplayItem()
{

}

RectangleDisplayItem::~RectangleDisplayItem()
{

}

void RectangleDisplayItem::Create(DisplayContext &dislpayEngine)
{
	DisplayItem::Create(dislpayEngine);
}

void RectangleDisplayItem::Render(DisplayContext &dislpayEngine)
{
	Matrix3x2F transform = Matrix3x2F::Translation(RenderTransform.TranslateX,RenderTransform.TranslateY);
	dislpayEngine.D2DContext->SetTransform(transform);
	//if(m_borderBrush.Get()==nullptr||m_borderBrush->GetColor().)
	{
		ColorF borderColor(BorderColor&0x00ffffff,(BorderColor>>24)/0xff);
		dislpayEngine.D2DContext->CreateSolidColorBrush(borderColor,&m_borderBrush);
	}
	//if(m_fillBrush==nullptr)
	{
		ColorF fillColor(FillColor&0x00ffffff,(FillColor>>24)/0xff);
		dislpayEngine.D2DContext->CreateSolidColorBrush(fillColor,&m_fillBrush);
	}

	dislpayEngine.D2DContext->FillRectangle(RectF(X,Y,Width+X,Height+Y),m_fillBrush.Get());
	dislpayEngine.D2DContext->DrawRectangle(RectF(X,Y,Width+X,Height+Y),m_borderBrush.Get(),BorderThickness);
}